package com.develop;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

import com.develop.BusinessGatewayService.BusinessGatewayService;

@SpringBootApplication
@ComponentScan("com.develop")
public class DevelopApplication implements CommandLineRunner {
	@Value("${businessGatewayService.server.bindPort}")
	private int port;
	@Autowired
	BusinessGatewayService businessGatewayService;
	ExecutorService fixedThreadPool = Executors.newFixedThreadPool(1);

	public static void main(String[] args) {
		SpringApplication.run(DevelopApplication.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
		fixedThreadPool.execute(() -> {
			try {
				businessGatewayService.run(port);
			} catch (Exception e) {
				e.printStackTrace();
			}
		});
	}
}
